var USER_TAG = (function() {
	function init() {
		var tagModalId = new Date().format("yyyyMMdd") + "_USER_TAG";
		var $modal = $("div#" + tagModalId);
		if ($modal.length) { // 存在
		} else {
			var m = '';
			m += '<div class="modal fade" id="' + tagModalId + '" tabindex="-1" role="dialog">';
				m += '<div class="modal-dialog" role="document">';
					m += '<div class="modal-content">';
						m += '<div class="modal-header" style="background-color: #f5f5f5;">';
							m += '<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>';
							m += '<h4 class="modal-title text-center">标签</h4>';
						m += '</div>';
						m += '<div class="modal-body" style="min-height: 400px; padding: 5px 15px;">';
							m += '<div class="row">';
								m += '<div class="col-xs-1"></div>';
								m += '<div class="col-xs-4">';
									m += '<select multiple class="form-control" style="height: 250px; min-height: 250px;" name="tagPool"></select>';
								m += '</div>';
								m += '<div class="col-xs-2 text-center">';
									m += '<div style="margin-top: 60px;"><i style="font-size: 25px;" class="fa fa-long-arrow-left"></i></div>';
									m += '<div style="margin-top: 60px;"><i style="font-size: 25px;" class="fa fa-long-arrow-right"></i></div>';
								m += '</div>';
								m += '<div class="col-xs-4">';
									m += '<select multiple class="form-control" style="height: 250px; min-height: 250px;" name="userTag"></select>';
								m += '</div>';
							m += '</div>';
							m += '<div class="row" style="margin-top: 15px;">';
								m += '<div class="col-xs-1"></div>';
								m += '<div class="col-xs-10" style="border-top: 1px solid #e5e5e5; padding-top: 5px;">';
									m += '<button type="button" class="btn btn-default" name="addTag">自定义标签</button>';
									m += '<button type="button" class="btn btn-default" name="replaceTag">修改标签</button>';
									m += '<button type="button" class="btn btn-default" name="removeTag">删除标签</button>';
									m += '<span class="tagAlert"></span>';
								m += '</div>';
							m += '</div>';
							m += '<div class="row tag-edit" style="margin-top: 15px; display: none;">';
								m += '<div class="col-xs-1"></div>';
								m += '<div class="col-xs-11 form-inline">';
									m += '<input type="text" class="form-control" name="tagNmae" placeholder="请输入标签名称">';
									m += '<input type="hidden" class="form-control" name="tagId">';
									m += '<button type="button" name="saveTag" class="btn btn-default">保存</button>';
								m += '</div>';
							m += '</div>';
						m += '</div>';
					m += '</div>';
				m += '</div>';
			m += '</div>';
			$modal = $(m).appendTo($("body"));
			$modal.find('button[name="addTag"]').on("click", function() {
				$modal.find('div.tag-edit').show();
				$modal.find('div.tag-edit input[name="tagNmae"]').val("");
			});
			$modal.find('button[name="replaceTag"]').on("click", function() {
				var $options = $('select[name="tagPool"]:checked');
				$modal.find('div.tag-edit').show();
				$modal.find('div.tag-edit input[name="tagNmae"]').val("");
			});
			
		}
		
		$modal.modal({keyboard:true});
	}
	
	return {
		init: init
	}
})();